﻿Imports System.Web.HttpContext
Imports System.IO

Public Class Logging
    Public Sub New()

    End Sub

    Public Sub WriteLog(ByVal sErrMsg As String, ByVal fileError As String)
        Dim sLogFormat As String = DateTime.Now.ToString() & " ==> "

        Dim sYear As String = DateTime.Now.Year.ToString()
        Dim sMonth As String = DateTime.Now.Month.ToString()
        Dim sDay As String = DateTime.Now.Day.ToString()

        Dim sErrorTime As String = sYear + sMonth + sDay
        Dim sPathName As String = Current.Server.MapPath("~/Logging/Log_" & sDay & "-" & sMonth & "-" & sYear & ".justin")

        If Not sErrMsg = "Thread was being aborted." Then
            Dim sw As New StreamWriter(sPathName, True)
            sw.WriteLine(sLogFormat & sErrMsg & " ==> " & fileError & " ==> " & Current.Request.UserHostAddress.ToString())
            sw.Flush()
            sw.Close()
        End If
    End Sub
End Class
